﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Products;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Product.GetCategoryHomepage(this.Rpcaregory);
        }
    }

    protected void Rpcaregory_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ListView products = (ListView)e.Item.FindControl("litsproduct");
        DataRowView dv = (DataRowView)e.Item.DataItem;
        products.DataSource=Product.GetProductByCatalog(Convert.ToInt16(dv.Row["Category_Id"]));
        products.DataBind();
    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        string query = "";
        string tam = "";
        if (this.drbrand.SelectedIndex != 0)
        {
            tam = "Brand_Id= ";
            tam += this.drbrand.SelectedValue.ToString();
            query += tam;
        }
        if (this.drpricemin.SelectedItem.ToString() != "0")
        {
            if (query != "") tam = " and ";
            else tam = "";
            tam += " (Products_Price between " + drpricemin.SelectedItem.ToString() + " and " + this.drpricemax.SelectedItem.ToString() + " )";
            query += tam;
        }
        Response.Redirect("http://localhost:2011/didong/search/default.aspx?query=" + query);
        
    }
}
